#include<bits/stdc++.h>
using namespace std;
int T, n;
int a[100005];
int idk[100005];
int func(){
    int last0 = -1, last1 = -1;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(idk[i]){
            if(last1 == a[i]) ans += a[i];
            last1 = a[i];
        }
        else{
            if(last0 == a[i]) ans += a[i];
            last0 = a[i];
        }
    }
    return ans;
}
int main()
{
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    //freopen("./CSP-S/color/color1.in", "r", stdin);
    cin >> T;
    while(T--){
        cin >> n;
        for(int i = 1; i <= n; i++){
            cin >> a[i];
        }
        int maxn = -1;
        for(int i = 0; i < (1 << n); i++){
            for(int j = 1; j <= n; j++){
                idk[j] = i & (1 << (j - 1));
                maxn = max(maxn, func());
            }
        }
        cout << maxn << endl;
    }
    return 0;
}

